<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .upload-wrapper{
            display: flex;
            align-items: center;
            width: 100px;
            height:100px;
            border: 1px dashed #20dd1d;
        }
        p{
            font-size: 12px;
            width: 100%;
            text-align: center;
        }

    </style>
</head>
<body>
    <div class="upload-wrapper">
        <p>拖拽到此处</p>
    </div>
</body>
<script>
    var div = document.querySelector('.upload-wrapper')
    div.addEventListener('dragover',e=>{
        e.preventDefault()
    })
    div.addEventListener('drop',e=>{
        e.preventDefault()
        console.log(e);
    //   e.dataTransfer.items
    var arr = Array.prototype.slice.call( e.dataTransfer.items)
        arr.forEach(item=>{
           if(item.type =='image/png'){
               var img = new Image()
               img.src =  URL.createObjectURL(item.getAsFile())
             e.target.appendChild(img)
           }
        })
    })
</script>
</html>